package com.sap.jcp.sm.web;

import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.sap.jcp.sm.dao.ConfigDAO;
import com.sap.jcp.sm.dao.ConfigDAOImpl;
import com.sap.jcp.sm.domain.Config;
import com.sap.jcp.sm.domain.Shift;

public class ConfigAction extends ActionSupport implements ModelDriven<Config>, SessionAware, RequestAware {

	private Map sessionMap;
	private Map request;
	private static final long serialVersionUID = 1L;
	ConfigDAO configDAO = new ConfigDAOImpl();
	Config config = new Config();
	
	@Override
	public Config getModel() {
		return config;
	}
	public String manageConfig() {
		configDAO.createOrUpdate(config);
		sessionMap.put("config", configDAO.list());
		return SUCCESS;
	}
	
	@Override
	public void setSession(Map<String, Object> arg0) {
		this.sessionMap = arg0;
		
	}
	@Override
	public void setRequest(Map<String, Object> arg0) {
		this.request = arg0;
	}
	
}
